package com.clstu.list;

import java.util.*;

public class ListFor {
    public static void main(String[] args) {
        //List list = new ArrayList();
        //List list = new LinkedList();
        List list = new Vector();//这三种方式对这三种对象遍历都完全一样，三种类都实现了List接口
        list.add("jack");
        list.add("tom");
        list.add("鱼香肉丝");
        list.add("北京烤鸭");
       Iterator iterator= list.iterator();
        System.out.println(" ========Iterator=====");
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }
        System.out.println("=======增强for======");
        for(Object obj:list){
            System.out.println(obj);
        }
        System.out.println(" ========普通for=======");
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
    }
}
